﻿Imports Microsoft.VisualBasic
Imports Microsoft.VisualBasic.CompilerServices
Imports Stickam_Client.My
Imports System
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Drawing
Imports System.Runtime.CompilerServices
Imports System.Windows.Forms

Namespace Stickam_Client
    <DesignerGenerated> _
    Public Class Form_Message
        Inherits Form
        ' Methods
        <DebuggerNonUserCode> _
        Public Sub New()
            AddHandler MyBase.FormClosing, New FormClosingEventHandler(AddressOf Me.Form_Message_FormClosing)
            AddHandler MyBase.Load, New EventHandler(AddressOf Me.Form_Message_Load)
            Me.InitializeComponent
        End Sub

        Private Sub AddFontText(ByVal Msg As String, ByVal font As String, ByVal fontColor As String, ByVal fontSize As Integer, ByVal isBold As Boolean, ByVal isItalics As Boolean, ByVal isUnderline As Boolean, ByVal newLine As Boolean)
            Dim num As Integer = 0
            If isBold Then
                num += 1
            End If
            If isItalics Then
                num = (num + 2)
            End If
            If isUnderline Then
                num = (num + 4)
            End If
            If (newLine AndAlso (Me.PrivateChat.TextLength > 0)) Then
                Msg = (ChrW(13) & ChrW(10) & Msg)
            End If
            Me.AddRichText(Msg, New Font(font, CSng((fontSize - 3)), DirectCast(num, FontStyle)), Globals.ColorFromString(fontColor))
        End Sub

        Private Sub AddRichText(ByVal Msg As String, ByVal FontType As Font, ByVal FontColor As Color)
            Me.PrivateChat.SelectionColor = FontColor
            Me.PrivateChat.SelectionFont = FontType
            Me.PrivateChat.AppendText(Msg)
        End Sub

        Private Sub ChatInput_KeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs)
            If (Strings.Asc(e.KeyChar) = 13) Then
                e.Handled = True
                Dim msg As String = Strings.Replace(Me.ChatInput.Text, ChrW(13) & ChrW(10), ChrW(13), 1, -1, CompareMethod.Binary)
                Me.ChatInput.Clear
                Me.AddFontText((Me.MyScreenName & ": "), "Arial", MySettingsProperty.Settings.FontColor, 12, False, False, False, True)
                Me.AddFontText(msg, MySettingsProperty.Settings.FontFamily, MySettingsProperty.Settings.FontColor, MySettingsProperty.Settings.FontSize, MySettingsProperty.Settings.FontBold, MySettingsProperty.Settings.FontItalics, MySettingsProperty.Settings.FontUnderline, False)
                Me.FormParent.SendPrivateMessage(Me.Form_userID, msg)
            End If
        End Sub

        <DebuggerNonUserCode> _
        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            Try 
                If (disposing AndAlso (Not Me.components Is Nothing)) Then
                    Me.components.Dispose
                End If
            Finally
                MyBase.Dispose(disposing)
            End Try
        End Sub

        Private Sub FontUpdated()
            Dim num As Integer = 0
            If MySettingsProperty.Settings.FontBold Then
                num += 1
            End If
            If MySettingsProperty.Settings.FontItalics Then
                num = (num + 2)
            End If
            If MySettingsProperty.Settings.FontUnderline Then
                num = (num + 4)
            End If
            Me.ChatInput.Font = New Font(MySettingsProperty.Settings.FontFamily, CSng((MySettingsProperty.Settings.FontSize - 3)), DirectCast(num, FontStyle))
            Me.ChatInput.ForeColor = Globals.ColorFromString(MySettingsProperty.Settings.FontColor)
        End Sub

        Private Sub Form_Message_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs)
            Me.FormParent.RemovePrivateMessage(Me.Form_userID)
            Me.Form_userID = ""
        End Sub

        Private Sub Form_Message_Load(ByVal sender As Object, ByVal e As EventArgs)
            Me.FontUpdated
        End Sub

        <DebuggerStepThrough> _
        Private Sub InitializeComponent()
            Dim manager As New ComponentResourceManager(GetType(Form_Message))
            Me.SplitContainer1 = New SplitContainer
            Me.PrivateChat = New RichTextBox
            Me.ChatInput = New TextBox
            Me.SplitContainer1.Panel1.SuspendLayout
            Me.SplitContainer1.Panel2.SuspendLayout
            Me.SplitContainer1.SuspendLayout
            Me.SuspendLayout
            Me.SplitContainer1.Dock = DockStyle.Fill
            Me.SplitContainer1.IsSplitterFixed = True
            Dim point As New Point(0, 0)
            Me.SplitContainer1.Location = point
            Me.SplitContainer1.Name = "SplitContainer1"
            Me.SplitContainer1.Orientation = Orientation.Horizontal
            Me.SplitContainer1.Panel1.Controls.Add(Me.PrivateChat)
            Me.SplitContainer1.Panel2.Controls.Add(Me.ChatInput)
            Me.SplitContainer1.Panel2MinSize = &H23
            Dim size As New Size(&HD1, &H7E)
            Me.SplitContainer1.Size = size
            Me.SplitContainer1.SplitterDistance = &H56
            Me.SplitContainer1.SplitterWidth = 1
            Me.SplitContainer1.TabIndex = 0
            Me.PrivateChat.Dock = DockStyle.Fill
            Me.PrivateChat.HideSelection = False
            point = New Point(0, 0)
            Me.PrivateChat.Location = point
            Me.PrivateChat.Name = "PrivateChat"
            Me.PrivateChat.ScrollBars = RichTextBoxScrollBars.ForcedVertical
            size = New Size(&HD1, &H56)
            Me.PrivateChat.Size = size
            Me.PrivateChat.TabIndex = 0
            Me.PrivateChat.Text = ""
            Me.ChatInput.Dock = DockStyle.Fill
            point = New Point(0, 0)
            Me.ChatInput.Location = point
            Me.ChatInput.Multiline = True
            Me.ChatInput.Name = "ChatInput"
            size = New Size(&HD1, &H27)
            Me.ChatInput.Size = size
            Me.ChatInput.TabIndex = 0
            Dim ef As New SizeF(6!, 13!)
            Me.AutoScaleDimensions = ef
            Me.AutoScaleMode = AutoScaleMode.Font
            size = New Size(&HD1, &H7E)
            Me.ClientSize = size
            Me.Controls.Add(Me.SplitContainer1)
            Me.FormBorderStyle = FormBorderStyle.SizableToolWindow
            Me.Icon = DirectCast(manager.GetObject("$this.Icon"), Icon)
            Me.Name = "Form_Message"
            Me.StartPosition = FormStartPosition.Manual
            Me.Text = "Private Message"
            Me.SplitContainer1.Panel1.ResumeLayout(False)
            Me.SplitContainer1.Panel2.ResumeLayout(False)
            Me.SplitContainer1.Panel2.PerformLayout
            Me.SplitContainer1.ResumeLayout(False)
            Me.ResumeLayout(False)
        End Sub

        Private Sub NewPrivateMessage(ByVal userID As String, ByVal msg As String, ByVal font As String, ByVal fontColor As String, ByVal fontSize As Integer, ByVal isBold As Boolean, ByVal isItalics As Boolean, ByVal isUnderline As Boolean)
            If (Me.Form_userID = userID) Then
                Me.AddFontText(Conversions.ToString(Operators.AddObject(Me.FormParent.Userlist.getParam(userID, Me.FormParent.Userlist.screenName), ": ")), "Arial", fontColor, 12, False, False, False, True)
                Me.AddFontText(msg, font, fontColor, fontSize, isBold, isItalics, isUnderline, False)
            End If
        End Sub


        ' Properties
        Friend Overridable Property ChatInput As TextBox
            <DebuggerNonUserCode> _
            Get
                Return Me._ChatInput
            End Get
            <MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode> _
            Set(ByVal WithEventsValue As TextBox)
                Dim handler As KeyPressEventHandler = New KeyPressEventHandler(AddressOf Me.ChatInput_KeyPress)
                If (Not Me._ChatInput Is Nothing) Then
                    RemoveHandler Me._ChatInput.KeyPress, handler
                End If
                Me._ChatInput = WithEventsValue
                If (Not Me._ChatInput Is Nothing) Then
                    AddHandler Me._ChatInput.KeyPress, handler
                End If
            End Set
        End Property

        Public Overridable Property FormParent As Form1
            <DebuggerNonUserCode> _
            Get
                Return Me._FormParent
            End Get
            <MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode> _
            Set(ByVal WithEventsValue As Form1)
                Dim handler As NewPrivateMessageEventHandler = New NewPrivateMessageEventHandler(AddressOf Me.NewPrivateMessage)
                Dim handler2 As FontUpdatedEventHandler = New FontUpdatedEventHandler(AddressOf Me.FontUpdated)
                If (Not Me._FormParent Is Nothing) Then
                    RemoveHandler Me._FormParent.NewPrivateMessage, handler
                    RemoveHandler Me._FormParent.FontUpdated, handler2
                End If
                Me._FormParent = WithEventsValue
                If (Not Me._FormParent Is Nothing) Then
                    AddHandler Me._FormParent.NewPrivateMessage, handler
                    AddHandler Me._FormParent.FontUpdated, handler2
                End If
            End Set
        End Property

        Friend Overridable Property PrivateChat As RichTextBox
            <DebuggerNonUserCode> _
            Get
                Return Me._PrivateChat
            End Get
            <MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode> _
            Set(ByVal WithEventsValue As RichTextBox)
                Me._PrivateChat = WithEventsValue
            End Set
        End Property

        Friend Overridable Property SplitContainer1 As SplitContainer
            <DebuggerNonUserCode> _
            Get
                Return Me._SplitContainer1
            End Get
            <MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode> _
            Set(ByVal WithEventsValue As SplitContainer)
                Me._SplitContainer1 = WithEventsValue
            End Set
        End Property


        ' Fields
        <AccessedThroughProperty("ChatInput")> _
        Private _ChatInput As TextBox
        <AccessedThroughProperty("FormParent")> _
        Private _FormParent As Form1
        <AccessedThroughProperty("PrivateChat")> _
        Private _PrivateChat As RichTextBox
        <AccessedThroughProperty("SplitContainer1")> _
        Private _SplitContainer1 As SplitContainer
        Private components As IContainer
        Public Form_userID As String
        Public MyScreenName As String
    End Class
End Namespace

